<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
        <title></title>
        <link type="text/css" href="editor/base.css" rel="StyleSheet">
        <script type="text/javascript" src="editor/editor.js"></script>
        <script type="text/javascript">
            //����ʼ��
        var guid = "1324481743";
        var sState = "iframe";
        var oContent="";//<div></div>";
        if(window.parent.document.getElementById(Request('id'))!=null){
            var oInput=window.parent.document.getElementById(Request('id'));
            var oForm=oInput.form;//window.parent.document.getElementById(Request('form_id'));
            oContent=oInput.value;
        }else{
            //alert(window.parent.document.getElementById(Request('input_id')));
            //alert("请向编辑器传入一个输入框的ID！");
        }
        function article_preview(){
            var editor_win = window.open('', "_blank", '');
            editor_win.document.open('text/html', 'replace');
            editor_win.opener = null ;
            editor_win.document.writeln($('editor_body_textarea').value);
            editor_win.document.close();
        }
        function getHTML(){ 
            if(editor_body_textarea.style.display=="none"){
                HTML=EDiaryEditor.iframe.contentWindow.document.body.innerHTML;
            }else{
                HTML=$('editor_body_textarea').value;
            }
            if(HTML=="<p>&nbsp;</p>") 
                HTML = "";
            if(HTML=="<P>&nbsp;</P>")
                HTML = "";
            return HTML;
            //alert(HTML);
        }
        function AttachSubmit(){
            oInput.value=getHTML();
            EDiaryEditor.delEditorRsave();
        }
        function AttachReset(){
            $('editor_body_textarea').value=oInput.value;
            EDiaryEditor.iframe.contentWindow.document.body.innerHTML=oInput.value;
        }
    
        if(document.attachEvent) oForm.attachEvent("onsubmit",AttachSubmit) ;
        else oForm.addEventListener('submit',AttachSubmit,false);
        if (! oForm.submitEditor) oForm.submitEditor = new Array() ;
        oForm.submitEditor[oForm.submitEditor.length] = AttachSubmit ;
        if (! oForm.originalSubmit) {
            oForm.originalSubmit = oForm.submit ;
            oForm.submit = function() {
                if (this.submitEditor) {
                    for (var i = 0 ; i < this.submitEditor.length ; i++) {
                        this.submitEditor[i]() ;
                    }
                }
                this.originalSubmit() ;
            }
        }
        if(document.attachEvent) oForm.attachEvent("onreset",AttachReset);
        else oForm.addEventListener('reset',AttachReset,false);
        if (! oForm.resetEditor) oForm.resetEditor = new Array() ;
        oForm.resetEditor[oForm.resetEditor.length] = AttachReset ;
        if (! oForm.originalReset) {
            oForm.originalReset = oForm.reset ;
            oForm.reset = function() {
                if (this.resetEditor) {
                    for (var i = 0 ; i < this.resetEditor.length ; i++) {
                        this.resetEditor[i]() ;
                    }
                }
                this.originalReset() ;
            }
        }
        function readCookie(name)
        {
            var cookieValue = "";
            var search = name + "=";
            if(document.cookie.length > 0)
            { 
                offset = document.cookie.indexOf(search);
                if (offset != -1)
                { 
                    offset += search.length;
                    end = document.cookie.indexOf(";", offset);
                    if (end == -1) end = document.cookie.length;
                    cookieValue = unescape(document.cookie.substring(offset, end))
                }
            }
            return cookieValue;
        }
        function writeCookie(name, value, hours)
        {
            var expire = "";
            if(hours != null)
            {
                expire = new Date((new Date()).getTime() + hours * 3600000);
                expire = "; expires=" + expire.toGMTString();
            }
            document.cookie = name + "=" + escape(value) + expire + ";path=/";
        }
                
        //�����ܳߴ�
        function AutoFit(){
            var a = parent.document.getElementsByTagName("IFRAME");
            for(var i=0; i<a.length; i++){
                if(a[i].src.indexOf("editor.htm")!=-1){
                    a[i].style.height=$("editor_body").offsetHeight;
                    a[i].style.width=$("editor_body").offsetWidth;
                }
            }
        }
        function init() {
            //writeCookie("EDiaryEditor_RSave", "true", 1);
            EDiaryEditor.initialize("EDiaryEditor", "editor_body", true, oContent);
            AutoFit();
        }
        </script>
    </head>
    <body>
        <div id="editor_body" style="width:625px;height:500px"></div>
        <script type="text/javascript">init()</script>
    </body>
</html>

